package com.guofen.controller.sjck;

import com.guofen.service.sjck.HistoryListService;
import com.guofen.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "HistoryListController", description = "温湿度数据表")
public class HistoryListController {

    @Autowired
    private HistoryListService historyListService;

    @ApiOperation("读出数据库中数据")
    @PostMapping("/searchByEquipNameAndTime")
    @ResponseBody
    private Result searchByEquipNameAndTime(@ApiParam(name = "signalName", value = "书柜名", required = true) @RequestParam("signalName") String signalName,
                                            @ApiParam(name = "startTime", value = "查询开始时间", required = true)@RequestParam("startTime") String startTime,
                                            @ApiParam(name = "endTime", value = "查询结束时间", required = true)@RequestParam("endTime") String endTime) {
        return historyListService.getAllHistoryList(signalName,startTime,endTime);
    }

    // 图表部分接口1.获得一个书柜下的数据集合。
    @ApiOperation("读出一个列下的温度数据集合")
    @PostMapping("/getTempByEquipAndTime")
    @ResponseBody
    private Result getTempByEquipAndTime(@ApiParam(name = "signalName", value = "书柜名", required = true)@RequestParam("signalName") String signalName,
                                         @ApiParam(name = "startTime", value = "查询开始时间", required = true)@RequestParam(value = "startTime") String startTime,
                                         @ApiParam(name = "endTime", value = "查询结束时间", required = true) @RequestParam(value = "endTime") String endTime) {
        return historyListService.getTempByEquipAndTime(signalName,startTime,endTime);
    }

    @ApiOperation("读出一个列下的湿度数据集合")
    @PostMapping("/getMoiByEquipAndTime")
    @ResponseBody
    private Result getMoiByEquipAndTime(@ApiParam(name = "signalName", value = "书柜名", required = true)@RequestParam("signalName") String signalName,
                                        @ApiParam(name = "startTime", value = "查询开始时间", required = true)@RequestParam(value = "startTime") String startTime,
                                        @ApiParam(name = "endTime", value = "查询结束时间", required = true) @RequestParam(value = "endTime") String endTime) {
        return historyListService.getMoiByEquipAndTime(signalName,startTime,endTime);
    }

    // 获得signalId与signalName之间的对应关系。
    @ApiOperation("得到所有列名")
    @GetMapping("/getAllSignalName")
    @ResponseBody
    private Result getAllSignalName() {
        return historyListService.getAllSignalName();
    }

}
